<template>
  <section class="wrapper">
    <myHeader :obj="myObj" @events="events"></myHeader>
    <main>
      <myNameCard :borderB="true" :faceUrl="myDate.HeadUrl">
        <span slot="name">{{myDate.Name}}</span>
        <span slot="info">{{myDate.Job?myDate.Job:"您暂不是行家"}}</span>
        <span slot="area">{{myDate.Introduc?myDate.Introduce:"请先申请成为行家"}}</span>
      </myNameCard>
      <div class="recommenBtn" @click="recommendoneself">自荐名片</div>
      <div class="recommenFriend">
        <div class="smallFace"></div>
        <div class="btn" @click="jumpWeb">推荐好友<i></i></div>
      </div>
    </main>
  </section>
</template>
<script>
import myHeader from './base/myHeader';
import myNameCard from './base/myNameCard';
import {Toast } from 'mint-ui';
import hgjSkip from '../assets/js/hgjSkip';
import API from '../assets/js/asktoses';
import { fetch,zdUrl,webUrl,chatAppId } from '../assets/api';
export default {
  data () {
    return {
      myObj: {
        text:"项目申请",
        type: 2
      },
      loginData:"",
      loginData:null,
      pic:this.$route.query.pic,
      myDate:{}
    }
  },
  created(){
    hgjSkip.skip().then(res =>{
      this.loginData = res;
      this.pic = this.b46Decode(this.$route.query.pic);
      this.myself();
    })
  },
  components: {
    myHeader,
    myNameCard
  },
  methods: {
    events(i){
      if(i == 2) {
        history.back();
      }
    },
    //转码
    b46Decode(str) {
      return decodeURIComponent(str);
    },
    //自荐
    async recommendoneself(){
      try{
        await fetch(API.getCoverAskToSes,{
          ...this.loginData[1],
          AskToSeeId: this.$route.query.AskToSeeId
        });
        Toast("自荐成功");
        history.back();
      }catch(e){
        
      }
    },
    //获取行家信息
    async myself(){
      let res = await fetch(API.getexpert,{
        ...this.loginData[1]
      });
      this.myDate = res.Result
    },
    jumpWeb(){
      let shareData = {CollectUrl:`${webUrl}classRoomDetails?AskToSeeId=${this.$route.query.AskToSeeId}`, CollectTitle:'分享好友', CollectImgUrl:this.pic};
      location.href = `${zdUrl}editShare?type=1&AppId=${chatAppId}&OpenId=${this.loginData[1].OpenId}&objs=${encodeURIComponent(JSON.stringify(shareData))}`;
    }
  }
}
</script>
<style lang="less" scoped>
  .wrapper {
    width: 3.75rem;
    height: 100%;
    main {
      width: 3.75rem;
      height: 100%;
      padding-top: .44rem;
      position: absolute;
      top: 0;
      left: 0;
      overflow-y: auto;
      box-sizing: border-box;
      .recommenFriend {
        width: 100%;
        height: .5rem;
        background: white;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 .15rem;
        box-sizing: border-box;
        .btn {
          font-size: .18rem;
          color: #555555;
          display: flex;
          align-items: center;
          i {
            display: block;
            width: .2rem;
            height: .2rem;
            background: url('../assets/img/icon_shape@3x.png') center center;
            background-size: cover;
            background-repeat: no-repeat;
          }
        }
        .smallFace {
          width: .25rem;
          height: .25rem;
          background: url('../assets/img/expert/icon_pp@3x.png') center center;
          background-size: cover;
          background-repeat: no-repeat;
        }
      }
      .recommenBtn {
        font-size: .2rem;
        color: #555555;
        height: .5rem;
        line-height: .5rem;
        background: white;
        text-align: center;
        margin-bottom: .08rem;
        
      }
    }
  }

</style>
